												
package com.module.device.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import base.util.Page;

import com.module.device.manager.DeviceActiveStatusManager;
import com.module.device.manager.DeviceLifecycleManager;
import com.module.device.manager.DeviceLoginRecordManager;
import com.module.device.manager.DeviceTypeManager;
import com.module.device.vo.DeviceLifecycle;


public class DeviceLifecycleService {

	DeviceActiveStatusManager activemanager = DeviceActiveStatusManager.getInstance();
	DeviceLoginRecordManager loginRecordmanager = DeviceLoginRecordManager.getInstance();
	DeviceTypeManager typemanager = DeviceTypeManager.getInstance();
	
	
	public Page list(DeviceLifecycle bean, Integer start, Integer limit)
			throws Exception {
		Page page = new Page();
		page.setStart(start);
		page.setLimit(limit);
		//bean.setUserId(LoginSession.getUserid());
		DeviceLifecycleManager manager = DeviceLifecycleManager.getInstance();
		page = manager.list(page, bean);
		List DeviceLifecyclelist = page.getRows();
//		
//		page.setRows(getEntDeviceList(DeviceLifecyclelist));
		
//		for(int i=0;i<DeviceLifecyclelist.size();i++)
//		{
//			DeviceLifecycle bean1 = (DeviceLifecycle) DeviceLifecyclelist.get(i);
//			System.out.println("===================="+bean1.getDeviceEntity().getDeviceType().getDeviceTypeName()+"===========");
//		}
		
		return page;
	}
	

	public Map<String,Object> remove(Long id)throws Exception{       
		Map<String,Object> map = new HashMap<String,Object>();
		DeviceLifecycleManager manager = DeviceLifecycleManager.getInstance();
		map = manager.delete(id);
		return map;
		
	}	


	public Map<String,Object> save(DeviceLifecycle bean)throws Exception{
		//bean.setOrgId(LoginSession.getOrgid());
		Map<String,Object> map = new HashMap<String,Object>();
		DeviceLifecycleManager manager = DeviceLifecycleManager.getInstance();
		map = manager.add(bean);
		return map;

	} 
	

	public DeviceLifecycle findById(Long id)throws Exception{
		DeviceLifecycle bean = new DeviceLifecycle();
		DeviceLifecycleManager manager = DeviceLifecycleManager.getInstance();
		bean = manager.findById(id);
		return bean;
	}
	
	public static void main (String args[]) throws Exception
	{
		DeviceLifecycleService dls = new DeviceLifecycleService();
		DeviceLifecycle bean = new DeviceLifecycle();
		dls.list(bean, 0, 10);
		
	}

}
